package com.wzdigit.wms.basic.enums;
import java.util.*;

/**
 * 货品清单状态
 * @author Administrator
 *
 */
public enum GoodsStatusEnum implements BaseEnum {

	CREATE(0, "新建", "Status"), 
	WAIT_IN(1, "待入库", "Status"),
	WAIT_UP(2, "待上架", "Status"),
	HAS_UP(3, "已上架", "Status"), 
	WAIT_DOWM(4, "已下架", "Status"),
	HAS_DOWN(5, "已拣选", "Status"),
	HAS_COMFIRM(6, "已复核", "Status"), 
	HAS_ZHUANGGUI(7, "已装柜", "Status"), 
	HAS_CHUKU(8, "已出库", "Status"), 
	HAS_TUIKU(9, "已退库", "Status"), 
	OUT_ONLOAD(10, "转出在途", "Status"),
	SCRAP(99, "报废", "Status");
	
	/**
	 * 枚举值
	 */
	public int code;

	/**
	 * 枚举名称
	 */
	public String enumName;

	/**
	 * 枚举实体类属性描述
	 *
	 * @return
	 */
	public String description;
	
	
	GoodsStatusEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}
	
	GoodsStatusEnum(int code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}
	
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public static GoodsStatusEnum getEnumByCode(int enumCode) {
		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		GoodsStatusEnum samplingEnum = null;

		for (GoodsStatusEnum value : values) {
			if (value.getCode() == enumCode) {
				samplingEnum = value;
			}
		}
		return samplingEnum;
	}

	public static GoodsStatusEnum getEnumByName(String enumName) {
		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		GoodsStatusEnum repairEnum = null;

		for (GoodsStatusEnum value : values) {
			if (value.getEnumName() == enumName) {
				repairEnum = value;
			}
		}
		return repairEnum;
	}

	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}
	
	public static Map<Integer, String> getEnumByDescription() {
		Map<Integer, String> enumMap = new HashMap<>();

		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		for (GoodsStatusEnum value : values) {
			enumMap.put(value.getCode(), value.getEnumName());
		}
		return enumMap;
	}

	public static Map<Integer, String> getEnumByDescription(String enumDescription) {
		Map<Integer, String> enumMap = new HashMap<>();

		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		for (GoodsStatusEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				enumMap.put(value.getCode(), value.getEnumName());
			}
		}
		return enumMap;
	}
	
	public static Integer getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		for (GoodsStatusEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)
					&& Objects.equals(value.getEnumName(), enumName)) {
				return value.getCode();
			}
		}
		return null;
	}

	
	public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		for (GoodsStatusEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				Map<String, Object> enumMap = new HashMap<String, Object>(2);
				enumMap.put("code", value.getCode());
				enumMap.put("name", value.getEnumName());
				list.add(enumMap);
			}
		}
		return list;
	}
	
	public static List<Map<String, Object>> getEnumListByDescription() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		GoodsStatusEnum[] values = GoodsStatusEnum.values();
		for (GoodsStatusEnum value : values) {
			Map<String, Object> enumMap = new HashMap<String, Object>(2);
			enumMap.put("code", value.getCode());
			enumMap.put("name", value.getEnumName());
			list.add(enumMap);
		}
		return list;
	}
	
	public static List<String> getEnumNameByCodeList(List<Integer> enumCodeList) {
		GoodsStatusEnum[] goodsStatusEnumList = GoodsStatusEnum.values();
		List<String> enumNameList = new ArrayList<>(enumCodeList.size());
		for (Integer enumCode : enumCodeList) {
			for (GoodsStatusEnum goodsStatusEnum : goodsStatusEnumList) {
				if(Objects.equals(enumCode, goodsStatusEnum.code)) {
					enumNameList.add(goodsStatusEnum.enumName);
				}
			}
		}
		return enumNameList;
	}
}
